/*
 * Copyright (c) 2008, Xiong Yingfei, the University of Tokyo All rights
 * reserved.
 */
package ac.jp.u_tokyo.SyncLib.tests;

import static org.junit.Assert.assertEquals;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import ac.jp.u_tokyo.SyncLib.PrimMod;
import ac.jp.u_tokyo.SyncLib.Value2Mod;
import ac.jp.u_tokyo.SyncLib.dictionaries.DictMod;
import ac.jp.u_tokyo.SyncLib.dictionaries.DictModFactory;

public class Map2DictModTest
{

	@Test
	public void testRemove()
	{
		Map<String, Integer> src = new HashMap<String, Integer>();
		Map<String, Integer> tgt = new HashMap<String, Integer>();
		src.put("abc", 1);
		final DictMod<String, Integer> result = (DictMod<String, Integer>) Value2Mod
				.findMod(src, tgt);
		assertEquals(1, result.size());
		
		DictModFactory<String, Integer> expected = new DictModFactory<String, Integer>();
		expected.addRemove("abc");
		assertEquals(expected.create(), result);
	}

	@Test
	public void testAdd()
	{
		Map<String, Integer> src = new HashMap<String, Integer>();
		Map<String, Integer> tgt = new HashMap<String, Integer>();
		tgt.put("abc", 1);
		final DictMod<String, Integer> result = (DictMod<String, Integer>) Value2Mod
				.findMod(src, tgt);
		assertEquals(1, result.size());

		DictModFactory<String, Integer> expected = new DictModFactory<String, Integer>();
		expected.addPut("abc", new PrimMod<Integer>(1));

		assertEquals(expected.create(), result);

	}

}
